# -*- coding: utf-8 -*-

# Copyright (C) 2010 David Byers <david.byers@liu.se>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import *

class InfoDialog(Plasma.Dialog):
    def init(self):
        self.persistent = False

        self.setWindowFlags(Qt.FramelessWindowHint | 
                            Qt.WindowStaysOnTopHint | 
                            Qt.X11BypassWindowManagerHint)
        self.setStyleSheet("padding-left:0;color: %s;" % Plasma.Theme.defaultTheme().color(Plasma.Theme.TextColor).name())
        self.layout = QVBoxLayout(self)
        self.layout.setContentsMargins(0,0,0,10)

        self.title = QLabel()
        self.title.setAlignment(Qt.AlignLeft)

        self.line2 = QLabel()
        self.line2.setAlignment(Qt.AlignLeft)

        self.progress = QProgressBar()
        self.progress.setOrientation(Qt.Horizontal)
        self.progress.setMinimum(0)
        self.progress.setMaximum(10000)
        self.progress.setValue(0)
        self.progress.setFormat("")
        self.progress.setMaximumHeight(5)

        self.layout.addWidget(self.title)
        self.layout.addWidget(self.line2)
        self.layout.addWidget(self.progress)

        self.setLayout(self.layout)

    def setData(self, song, artist, album):
        self.title.setText("<b>" + song + "</b>")
        if artist and album:
            self.line2.setText(artist + ": " + album)
        else:
            self.line2.setText(artist + album)

    def setProgress(self, progress):
        self.progress.setValue(int(progress * 10000))
